<?php
require_once dirname(__FILE__).'/../../rightMenuWidget/lib/RightMenuHelper.class.php';

class redirectMeDownComponents extends myComponents{

	public function executeRender()
  {
    if(!$this->getRoute()->getCategoryObject()) {
      $category = new ProductGroup;
      $redirect = array(
        $_SERVER['HTTP_HOST'],
        $this->getObject()->getLang(),
        $this->getObject()->getTitle() . '.c'
      );
      
      $category = $category->getAll($this->getObject(), $this->getUser());
      
      if($category->count()) {
        $category   = $category->toArray();
        $redirect[] = $category[0]['Translation'][$this->getUser()->getculture()]['slug'];
        
        $this->getAction()->redirect('http://' . implode('/', $redirect));
      }
    }
		
		return sfView::NONE;
	}
}